<template>
	<view class="detail">
		<!-- 头部 -->
		<view class="detail_title" :class="dataObj.status == 'normal'?'backgroundColor_6bcbb6':'backgroundColor_989898'">
			<view class="title_top flex-row-start">
				<image v-if="dataObj.status == 'normal'" src="@/static/my/qryes_a.png" mode=""></image>
				<image v-else src="@/static/my/qryes_b.png" mode=""></image>
				<view class="font18 font-ffffff">{{dataObj.typename}}</view>
			</view>
			<view class="font15 font-ffffff">请注意体检时间,以免作废</view>
		</view>
		<!-- 边框 -->
		<view class="com_border"></view>
		<!-- 体检信息 -->
		<view class="det_title font-323232 font15 font-b">体检信息</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between">
			<text>体检人</text>
			<view>{{dataObj.physical_user_name}}</view>
		</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between">
			<text>体检人手机</text>
			<view>{{dataObj.physical_user_mobile}}</view>
		</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between">
			<text>体检时间</text>
			<view>{{dataObj.time}} {{dataObj.begin_time}}~{{dataObj.end_time}}</view>
		</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between">
			<text>咨询电话</text>
			<view>{{conobj.physical_h_tel}}</view>
		</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between">
			<text>体检地址</text>
			<view>{{conobj.physical_h_addr}}</view>
		</view>
		<view class="detail_h"></view>
		<!-- 边框 -->
		<view class="com_border"></view>
		<!-- 缴费详情 -->
		<view class="det_title font-323232 font15 font-b">缴费详情</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between">
			<text>支付金额</text>
			<view>{{dataObj.money}}</view>
		</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between">
			<text>下单时间</text>
			<view>{{dataObj.createtime}}</view>
		</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between" v-if="dataObj.pay_status==1">
			<text>支付时间</text>
			<view>{{dataObj.pay_status}}</view>
		</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between" v-if="dataObj.pay_status==2&&dataObj.status=='cancel'">
			<text>取消时间</text>
			<view>{{dataObj.cancel_time}}</view>
		</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between" v-if="dataObj.pay_status==1&&dataObj.status=='refund'">
			<text>退款时间</text>
			<view>{{dataObj.refundtime}}</view>
		</view>
		<view class="detail_info font-9c9c9d font15 flex-row-between">
			<text>订单编号</text>
			<view>{{dataObj.order_code}}</view>
		</view>
		<view class="detail_h"></view>
		<!-- 边框 -->
		<view class="com_border"></view>
		<!-- 套餐详情 -->
		<view class="det_title font-323232 font15 font-b">套餐详情</view>
		<view class="pay_package">
			<view v-for="(item,index) in packageList" :key="index" class="package_list">
				<view class="package_title font14 font-878787 flex-row-start">{{item.name}}({{item.physical_project_number}})项</view>
				<view class="package_bos">
					<view class="package_box font14 font-646464" v-for="(item1,index1) in item.physical_project" :key="index"
						:class="index1==item.physical_project.length-1?'package_box_0':''">
						<view class="package_box_title">{{item1.name}}</view>
						<view class="package_box_info">{{item1.synopsis}}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 取消预约 -->
		<view class="pay_menu flex-row-between">
			<view class="font13" @click="Onhome">回首页</view>
			<view v-if="dataObj.status=='normal'" class="menu_submit flex-row-center font-ffffff font13" @click="Oncolse">取消预约</view>
		</view>
		<view class="pay_menus"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				conobj:{},
				dataObj: {}, //详情
				getobj: {}, //项目详情
				code: null, //订单code
				type: true,
				// 套餐详情
				packageList: []
			}
		},
		onLoad: function(options) {
			this.code = options.code
			//订单详情
			this.Ondetails()
			//公共接口
			this.Onconfig()
		},
		methods: {
			Onconfig() {
				this.$Http({
					url: 'consultationConsult',
					data: {}
				}).then(res => {
					if (res.code == 1) {
						this.conobj = res.data
					}
				})
			},
			//订单详情
			Ondetails() {
				this.$Http({
					url: 'detailsPhysicalOrder',
					data: {
						order_code: this.code
					}
				}).then(res => {
					if (res.code == 1) {
						res.data.createtime = this.$base.formatTime(new Date(res.data.createtime *
							1000), "yyyy/MM/dd hh:mm:ss")
						if (res.data.pay_status == 1 && res.data.pay_time) {
							res.data.pay_time = this.$base.formatTime(new Date(res.data.pay_time *
								1000), "yyyy/MM/dd hh:mm:ss")
						}
						if (res.data.status == 'refund' && res.data.refundtime) {
							res.data.refundtime = this.$base.formatTime(new Date(res.data.refundtime *
								1000), "yyyy/MM/dd hh:mm:ss")
						}
						if (res.data.status == 'cancel' && res.data.cancel_time) {
							res.data.cancel_time = this.$base.formatTime(new Date(res.data.cancel_time *
								1000), "yyyy/MM/dd hh:mm:ss")
						}
						if(res.data.pay_status == 2 && res.data.status == 'normal'){
							res.data.typename = '待支付'
						}
						if(res.data.pay_status == 2 && res.data.status == 'cancel'){
							res.data.typename = '已取消'
						}
						if(res.data.pay_status == 1 && res.data.status == 'normal'){
							res.data.typename = '预约成功'
						}
						if(res.data.pay_status == 1 && res.data.status == 'refund'){
							res.data.typename = '已退款'
						}
						this.dataObj = res.data
						//获取项目详情
						this.Getinfo()
						//修改头部颜色
						this.BarColor()
					}
				})
			},
			//获取项目详情
			Getinfo() {
				this.$Http({
					url: 'physicalDetails',
					data: {
						physical_id: this.dataObj.physical_id
					}
				}).then(res => {
					if (res.code == 1) {
						this.getobj = res.data
						this.packageList = res.data.physical_project
					}
				})
			},
			//修改头部颜色
			BarColor() {
				wx.setNavigationBarColor({
					frontColor: '#ffffff', // 必写项
					backgroundColor: this.dataObj.status == 'normal' ? '#6bcbb6' : '#989898', // 必写项
				})
			},
			OnList() {
				uni.navigateTo({
					url: '/pagesA/check/list/list',
				})
			},
			//取消订单
			Oncolse(e) {
				var that = this
				let url = ''
				if (this.dataObj.pay_status == 2) {
					url = 'cancelPhysicalOrder'
				}
				if (this.dataObj.pay_status == 1) {
					url = 'refundPhysicalOrder'
				}
				uni.showModal({
					title: '取消体检提示',
					content: '取消后您将失去本号源,是否确认取消',
					confirmText: '保留号源', //确定文字
					confirmColor: '#6bcbb6',
					cancelText: '确定取消', //取消文字
					cancelColor: '#9c9c9c',
					success(res) {
						if (res.confirm) {} else if (res.cancel) {
							that.$Http({
								url: url,
								type: 'POST',
								show: true,
								data: {
									order_code: this.dataObj.order_code,
								}
							}).then(res => {
								if (res.code == 1) {
									that.Ondetails()
								}
							})
						}
					}
				})
			},
			Onhome(){
				uni.switchTab({
					url: '/pages/home/index'
				});
			}
		}
	}
</script>

<style lang="less">
	@import url("detail.less");
</style>
